<?php
class Fibonnaci implements Iterator
{
private $numer;
private $index;
public function rewind()
{
$this->numer = 0;
$this->index = 0;
}
public function current(){
return $this->number++;
}
public function key() { return $this->index; }
public function valid() { return $this->number; }
public function next(){ $this->numer= $this->numer++; $this->index == $this->index++; }
}
$fib = new Fibonnaci();
foreach($fib as $nextNumber)
echo $nextNumber, ' ' ;
1